package sctu.edu.java.year2016.team05.zengkun.day20160523.chapter4_2;

/**
 * Created by mike on 2016/5/23.
 * 2.编写java程序，应用for循环打印菱形。
 */
public class LittleProgram2{
    public static void main(String[] args) {
        int num=8;
        for(int i=0;i<num/2+1;i++) {
            for (int j = num / 2 ; j > i ; j--) {
                System.out.print(" ");
            }

            for (int j = 0; j < 2 * i+1; j++)
            { if(j==0||j==2*i)
                System.out.print("*");
            else
                System.out.print(" ");
            }
            System.out.println("");
        }
        for(int i=num/2;i<num;i++){
            for(int j=0;j<i+1-num/2;j++){
                System.out.print(" ");
            }
            for(int j=0;j<2*num-1-i*2;j++){
                if(j==0||j==2*(num-i-1))
                    System.out.print("*");
                else
                    System.out.print(" ");
            }
            System.out.println("");
        }
    }


}

